﻿using Pdoxcl2Sharp;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using V3MainTool.Model;

namespace V3MainTool
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        private string configPath = "./gamepath.txt";
        public static MainWindow Instance { get; private set; }
        public MainWindow()
        {
            InitializeComponent();
            this.Title = "v3 mod 工具, 版本：" + Model.Version.MyVersion + "  针对 v3 版本: " + Model.Version.V3Version;
            Instance = this;
            if (File.Exists(configPath))
            {
                gamepath = tbPath.Text = File.ReadAllText(configPath).Trim();
            }
        }

        public string GetFold()
        {
            return gamepath;
        }

        private string gamepath = "";
        private bool editState = false;
        private void btnEditPath_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                editState = !editState;
                tbPath.IsReadOnly = !editState;
                btnEditPath.Content = editState ? "确定" : "修改";
                if (!editState)
                {
                    gamepath = tbPath.Text.Trim();
                    if (File.Exists(configPath))
                    {
                        File.Delete(configPath);
                    }
                    File.WriteAllText(configPath, tbPath.Text.Trim());
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }
        }
    }
}
